//
//  SearchViewModel.m
//  Toyohu
//
//  Created by GuoPeng on 16/4/26.
//  Copyright © 2016年 celia. All rights reserved.
//

#import "SearchViewModel.h"
#import "GPAFNetworking3.h"


@implementation SearchViewModel

+ (NSArray *)getTagName:(void(^)(NSArray *tagNameArray))tagName tags:(void(^)(NSArray *tagsArray))tags error:(void (^)(NSString *))error
{
    NSMutableArray *tagArray = [NSMutableArray arrayWithCapacity:0];
    [GPAFNetworking3 post:GetTags parameters:@{} progress:nil success:^(id  _Nullable responseObject) {
        SearchBase *model = [[SearchBase alloc] initWithDictionary:responseObject];
        if (model.code == 1) {
            NSMutableArray *tagArray = [NSMutableArray arrayWithCapacity:0];
            for (SearchMsg *msgModel in model.msg) {
                [tagArray addObject:msgModel.htName];
            }
            tagName(tagArray);
            tags(model.msg);
        }else{
            error( [[responseObject objectForKey:@"msg"] isEqual:[NSNull null]] ? nil : [responseObject objectForKey:@"msg"]);
        }
    } failure:^(NSString * _Nonnull errorLD) {
        error(errorLD);
    }];
    return tagArray;
}

@end
